package com.aerotechnic.dao.implementation;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.aerotechnic.dao.interfaces.EventDaoIn;
import com.dhtmlx.planner.DHXEv;

@Repository
public class EventDao implements EventDaoIn {

	@Autowired
	private SessionFactory sessionFactory;

	private Session getCurrentSession() {
		return sessionFactory.getCurrentSession();
	}

	@Override
	public List<DHXEv> getAll() {
		// TODO Auto-generated method stub
		return getCurrentSession().createQuery("from Event").list();
	}

	@Override
	public void save(DHXEv evt) {
		// TODO Auto-generated method stub
		getCurrentSession().save(evt);
		
	}

	@Override
	public void update(DHXEv evt) {
		// TODO Auto-generated method stub
		getCurrentSession().update(evt);
		
	}

	@Override
	public void delete(DHXEv event) {
		// TODO Auto-generated method stub
		getCurrentSession().delete(event);
	}

}
